package com.mediacloud.app.newsmodule.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.util.TypedValue
import com.mediacloud.app.model.activity.BaseBackActivity
import com.mediacloud.app.model.news.CatalogItem
import com.mediacloud.app.newsmodule.R
import com.mediacloud.app.newsmodule.fragment.video.vod.SmallVideoNewsListFragment

/**
 * 小视频导航独立页面
 * wy
 * */
class SmallVideoGridActivity : BaseBackActivity() {

    var fragment: SmallVideoNewsListFragment? = null

    companion object {
        fun startActivity(context: Context, title: String?, catalogId: String?, catalogItem : CatalogItem) {
            val intent = Intent()
            intent.setClass(context, SmallVideoGridActivity::class.java)
            intent.putExtra("title", title)
            intent.putExtra("id", catalogId)
            intent.putExtra("catalog", catalogItem)
            context.startActivity(intent)
        }
    }

    override fun getLayoutResID(): Int {
        return R.layout.activity_small_video_grid
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        var title = intent.getStringExtra("title")
        title = if (TextUtils.isEmpty(title)) resources.getString(R.string.small_video) else title
        setTitle(title)
        if (mTitlebar_name != null) {
            mTitlebar_name.paint.isFakeBoldText = false
            mTitlebar_name.includeFontPadding = false
            mTitlebar_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimensionPixelSize(R.dimen.dimen20sp).toFloat())
        }
        val manager = supportFragmentManager
        val transaction = manager.beginTransaction()
        fragment = SmallVideoNewsListFragment()
        fragment!!.arguments = intent.extras
        transaction.add(R.id.baoliao_container, fragment!!)
        transaction.commitNowAllowingStateLoss()
    }

}